Ext.define('xyc.view.SendplaceList', {
    extend: 'Ext.Panel',
    xtype: 'sendplaceList',
    requires: [
        'xyc.model.Place','xyc.view.SendList'
    ],
    config: {
        layout: 'card',
        groupByDay: true,
        loadingText: '加载中...'
    },
    initialize: function () {
        this.callParent();
        this.searchstore = new Ext.data.Store({
            model: 'xyc.model.Place',
            autoLoad: true,
            sorters: '',
            proxy: {
                type: 'ajax',
                url: server+'/ext/com.cinsea.mobile.ext.XycAction?action=sendplacelist',
                reader: {
                    type: 'json',
                    rootProperty: 'result'
                }

            }
        })
        this.list = new Ext.List({
            id: 'sendplaces',
            itemTpl: '<span class="name">{title}</span> ',
            loadingText: false,
            store: this.searchstore
        });


        this.list.on('itemtap', this.onSelect, this);
        this.listpanel = new Ext.Panel({
            items: this.list,
            layout: 'fit'
        });
        this.listpanel.refresh = function () {
            Ext.getCmp('sendplaces').getStore().load()
        }
        this.listpanel.add({
                    xtype: 'toolbar',
                    docked: 'top',
                    layout: { pack: 'left' },
                    items: [
                        {
                            ui: 'back',
                            text: '返回',
                            scope: this,
                            handler: function () {
                                this.getParent().setActiveItem(this.prevCard, {
                                    type: 'slide',
                                    reverse: true,
                                    scope: this,
                                    after: function () {
                                        this.destroy();
                                    }
                                });
                            }
                        }
                    ]
                });

        // Take off the spinner
        //this.list.el.unmask();

        this.add(this.listpanel);

    },

    onSelect: function (v, i) {
        record = this.searchstore.getAt(i);
        if (record !== undefined) {
            var sessionCard = new xyc.view.SendList({
            });
            sessionCard.setPrevcard(this.listpanel);
            sessionCard.setProcessid(record.data.processid,record.data.title);

            this.setActiveItem(sessionCard, 'slide');

        }

    },
    setPrevcard: function (prevc) {
        this.prevCard = prevc;
    }

});
